/**
 * UnmonitorInstances.java
 * ************************** 
 * @date May 28, 2011
 * @author Michele Tamburini
 * 
 * **************************
 */
package infrastructureAPI.algorithms.monitorTools;

import infrastructureAPI.Requester;
import infrastructureAPI.Service;
import infrastructureAPI.APIMessages.RequestMessage;
import infrastructureAPI.algorithms.APIFunction;
import infrastructureAPI.algorithms.GeneralAPIFunctionAlgorithm;
import infrastructureAPI.backendGate.APIScript;

import java.net.InetAddress;
import java.util.List;
import java.util.Vector;

/**
 * Description: 
 *
 */
public class UnmonitorInstances extends GeneralAPIFunctionAlgorithm 
		implements APIScript {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * @param requester
	 */
	public UnmonitorInstances(Requester requester) {
		super(requester);
	}
	
	protected UnmonitorInstances() {}


	@Override
	public RequestMessage createRequestMessage(InetAddress targetAddress,
			String targetNodeName) {
		return defaultRequestMessageComposition(targetAddress, targetNodeName);
	}

//	@Override
//	public boolean executeAlgorithm(List<Service> services) {
//		MonitoringService monitor = (MonitoringService) services.get(0);
//		monitor.stopMonitor();
//		return true;
//	}

	@Override
	public Service extractSuppliedService() {
		return null;
	}

	@Override
	public boolean requireSystemRegistration() {
		return false;
	}

	@Override
	public List<Class<?>> requiredServices() {
		List<Class<?>> services = new Vector<Class<?>>();
		services.add(MonitoringService.class);
		return services;
	}

	@Override
	public int mandatoryParametersNumber() {
		return 0;
	}

	@Override
	public String showUsage() {
		return null;
	}

	@Override
	public Service extractServiceToDeRegister() {
		return new MonitorInstancesThread();
	}

	@Override
	public boolean requireSystemDeRegistration() {
		return true;
	}

	@Override
	public boolean requireReply() {
		return true;
	}

	@Override
	public void run() {
		MonitoringService monitor = (MonitoringService) services.get(0);
		monitor.stopMonitor();
		returnValue = true;
	}

}
